package com.samehope.ar.mapper;

import com.samehope.ar.entity.PatrolPoint;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.samehope.ar.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 巡检点 Mapper 接口
 * </p>
 *
 * @author Zhang Luo
 * @since 2019-12-23
 */
public interface PatrolPointMapper extends BaseMapper<PatrolPoint> {

    /**
     * 获取巡检点树结构
     * @param projectId
     * @param condition
     * @return
     */
    List<TreeDataVO> getTreeByProjectAndCondition(@Param("projectId") Long projectId,
                                                  @Param("condition") String condition);

    /**
     * 获取巡检点明细
     * @param projectId
     * @param pointId
     * @return
     */
    PointDetailVO getDetailByProjectAndPoint(@Param("projectId") Long projectId,
                                             @Param("pointId") Long pointId);

    /**
     * 根据项目和巡检点查询巡检点对象
     * @param projectId
     * @param pointId
     * @return
     */
    PatrolPoint findByProjectAndPoint(@Param("projectId") Long projectId,
                                      @Param("pointId") Long pointId);

    /**
     * 根据项目和点位名称查询点位对象
     * @param projectId
     * @param pointName
     * @return
     */
    PatrolPoint getPointByProjectAndPointName(@Param("projectId") Long projectId,
                                              @Param("pointName") String pointName);

    /**
     * 根据点位统计巡检历史
     * @param patrolPointId
     * @return
     */
    PatrolPointCountVO countByPoint(@Param("patrolPointId") Long patrolPointId
                                    , @Param("startTime")String startTime
                                    , @Param("endTime")String endTime);

    /**
     * 根据点位统计问题分布情况
     * @param patrolPointId
     * @param startTime
     * @param endTime
     * @return
     */
    List<ChartDataVo> countByProblemType(@Param("patrolPointId") Long patrolPointId
            , @Param("startTime")String startTime
            , @Param("endTime")String endTime);

    List<ChartDataVo> countByProblemItem(@Param("patrolPointId") Long patrolPointId
            , @Param("startTime")String startTime
            , @Param("endTime")String endTime);

    /**
     * 获取巡检点树结构, 没有点位的分类不显示
     * @param projectId
     * @return
     */
    List<TreeDataVO> getTreeWithFullNodeByProject(Long projectId);
}
